<?PHP
	/************************************************************************
	*       This file, in addition to all other parts of X7 Chat are        *
	*                   Copyright 2003-2007 by Tim Chamness.                *
	* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
	* Version:          X7 Chat 3.0.0-A2                                    *
	* Release Date:     October 20, 2007                                    *
	* Author:           Tim Chamness                                        *
	* Copyright:        2003-2007 by Tim Chamness                           *
	* Website:          http://www.x7chat.com/                              *
	* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
	* X7 Chat 3 is free software; you can redistribute it and/or modify     *
	* it under the terms of the GNU General Public License as published by  *
	* the Free Software Foundation; either version 3 of the License, or     *
	* (at your option) any later version.                                   *
	*                                                                       *
	* X7 Chat 3 is distributed in the hope that it will be useful, but      *
	* WITHOUT ANY WARRANTY; without even the implied warranty of            *
	* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
	* General Public License for more details.                              *
	*                                                                       *
	* You should have received a copy of the GNU General Public License     *
	* along with this program.  If not, see <http://www.gnu.org/licenses/>. *
	*                                                                       *
	* Additional Terms, compatible with Section 7 of the GNU GPL v3,        *
	* apply to X7 Chat 3 and all X7 Chat 3 files, including this one.       *
	* You should have received a copy of these Additional Terms in the      *
	* file docs/COPYING.ADDITIONAL_TERMS.  If you did not receive a copy    *
	* please visit <http://www.x7chat.com/COPYING.ADDITIONAL_TERMS/>.       *
	************************************************************************/

	$GLOBALS['OUTPUT']->master_section = 'tools';
	$GLOBALS['OUTPUT']->minor_section = $GLOBALS['LANG']->lang_admin->tools_main;
	$GLOBALS['OUTPUT']->cpmenu = $menus[$GLOBALS['OUTPUT']->master_section];
	
	/*
	// FTP access required
	class_exists('lib_ftp') || require('./libraries/lib_ftp.php');
	$ftperrors = array();
	
	$host = x7in::read('ftphost');
	if(!empty($host)){
		$user = x7in::read('ftpuser');
		$pass = x7in::read('ftppass');
		$saveftppass = x7in::read('saveftppass');
		$ftppath = x7in::read('ftppath');
		
		$update_settings = ($user != $settings['ftpuser'] || $host != $settings['ftphost'] || $saveftppass != $settings['saveftppass'] || $ftppath != $settings['ftppath'] || ($saveftppass && $pass != $settings['ftppass']));
		$settings['ftphost'] = $host;
		$settings['ftpuser'] = $user;
		$settings['saveftppass'] = ($saveftppass != '');
		$settings['ftppath'] = $ftppath;
		
		if($update_settings){
			$settings['ftppass'] = $saveftppass ? $pass : '';
			$settings['key'] = 'settings';
			$GLOBALS['DATABASE']->put('system',$settings);
		}
		
		$settings['ftppass'] = $pass;
	}
	
	$askforftp = (empty($settings['ftppass']) || empty($settings['ftpuser']) || empty($settings['ftphost']) || empty($settings['ftppath']));
	if(!$askforftp){
		// Attempt ftp connection
		$ftp = new lib_ftp($settings['ftphost'],$settings['ftpuser'],$settings['ftppass'],$settings['ftppath']);
		if(!empty($ftp->error)){
			$askforftp = true;
			switch($ftp->error){
				case 'connection_failure':
					$ftperrors['ftphost'] = $GLOBALS['OUTPUT']->lang['invalid_ftp_host'];
				break;
				case 'login_failure':
					$ftperrors['ftpuser'] = $GLOBALS['OUTPUT']->lang['ftp_login_failure'];
					$ftperrors['ftppass'] = $GLOBALS['OUTPUT']->lang['ftp_login_failure'];
				break;
				case 'bad_directory':
					$ftperrors['ftppath'] = $GLOBALS['OUTPUT']->lang['invalid_ftppath'];
				break;
			}
		}
	}
	
	if($askforftp){
		$GLOBALS['OUTPUT']->display('ftpprompt.php',array('ftp_defaults'=>$settings,'ftp_errors'=>$ftperrors,'after_action'=>'&page=tools'));
	}else{
		echo "procede with FTP action";
	}
	exit;
	*/
	$data = unserialize(implode('',file("http://www.x7chat.com/updates/updates.php?x=data")));
	
	$GLOBALS['OUTPUT']->version = $X7_CHAT_VERSION;
	$GLOBALS['OUTPUT']->lastestver = $data['curversion'][1];
	$GLOBALS['OUTPUT']->news = $data['news'];
	
	echo tpl_tools::tools();
?>